package com.mh.jdbc.util;

public class StringUtil {
	/**
	 * 判断是否为空
	 * @param s
	 * @return
	 */
	public static boolean isEmpty(String s){
		if(null == s || "".equals(s.trim())) return true;
		return false;
	}
	/**
	 * 判断是否不为空
	 * @param s
	 * @return
	 */
	@SuppressWarnings("null")
	public static boolean isNotEmpty(String s){
		if(null != s || !"".equals(s.trim())) return true;
		return false;
	}
	/**
	 * 判断字符是否为数字
	 */
	public static boolean isNum(char c){
		if(c<58 && c >47) return true;
		return false;
	}
	/**
	 * 从字符串中提取数字
	 * @param s
	 * @return
	 */
	public static int getNum(String s){
		StringBuilder sb = new StringBuilder();
		char tmp = 0;
		for(int i=0,len = s.length(),mark=0;i<len;i++){
			tmp = s.charAt(i);
			if(isNum(tmp)){
				mark = i+1;
				sb.append(tmp);
				if(mark<len && !isNum(s.charAt(mark))) break;
			}
		}
		return Integer.parseInt(sb.toString());
	}
}
